package org.wh1tew0lf.vframe.framework;

import java.util.Map;

import org.wh1tew0lf.vframe.framework.vframeexception.VFrameException;

public enum VDatabaseValueOperator implements IDatabaseOperator {
	STRING("'##VALUE_0##'", "", false),
	MIN("(MIN(##VALUE_0##))", "", false),
	MAX("(MAX(##VALUE_0##))", "", false),
	AVG("(AVG(##VALUE_0##))", "", false),
	COUNT("(COUNT(##VALUE_0##))", "", false),
	FIELD("##FIELD##", "", false),
	NULL("##VALUE_0##", "", false), 
	ORACLE_TEXT_WITHIN("(##VALUE_1## WITHIN ##VALUE_0##)", "", true);

	private String formatText;
	private String seperator;
	private boolean rawValueData;

	private VDatabaseValueOperator(String formatText, String seperator, boolean rawValueData) {
		this.formatText = formatText;
		this.seperator = seperator;
		this.rawValueData = rawValueData;
	}

	@Override
	public String toString(boolean rawValueData, String fieldName, Map<String, String> fieldNameMap,
			IDatabaseRestriction... restrictions) throws VFrameException {
		String realFormatText = rawValueData ? "##VALUE_0##" : this.formatText;
		return AbstractDatabaseOperator.toString(this.rawValueData, realFormatText, seperator,
				fieldName, fieldNameMap, restrictions);
	}
	
	public String toString(boolean rawValueData, String value) {
		String realFormatText = rawValueData ? "##VALUE_0##" : this.formatText;
		return realFormatText.replace("##VALUE_0##", value);
	}
}
